#include "editor/property.h"
#include "ui/controls.h"
#include "ui/helpers.h"

using namespace std;
using namespace anip;
using namespace anip::editor;

struct NumProperty::Impl
{
	ui::Control* begin = nullptr, * end = nullptr;
	ui::Slider* slider = nullptr;
	ui::TextField* text = nullptr;
};

NumProperty::NumProperty(const wstring& name, const wstring& description, 
	float val, float min, float max)
	: _name(name), _desc(description), value(val), _pimpl(new Impl())
{
	setRange(min, max);
}

// ANIP_TODO: Can you try to comprehend why editor::drawing::PenTool doesn't
// need a destructor defined in src file in order to get unique_ptr<Impl>
// working?
NumProperty::~NumProperty() = default;

void NumProperty::setRange(float min, float max)
{
}

void NumProperty::createUI(ui::Container& c)
{
	if (_pimpl->begin != nullptr) return;




}

void NumProperty::destroyUI(ui::Container& c)
{
	if (_pimpl->begin != nullptr)
	{
		_pimpl->begin->markDelete();
		_pimpl->end->markDelete();
		_pimpl->begin = nullptr;
		_pimpl->end = nullptr;
	}
	if (_pimpl->slider != nullptr)
	{
		_pimpl->slider->markDelete();
		_pimpl->slider = nullptr;
	}
	if (_pimpl->text != nullptr)
	{
		_pimpl->text->markDelete();
		_pimpl->text = nullptr;
	}
}